import java.util.Stack;

public class Solution71 {
    public String simplifyPath(String path) {
        String[] con=path.split("/");
        Stack<String> stack=new Stack<>();
        for (String s : con) {
            if (s.length()==0||s.equals(".")){
                continue;
            }
            if (s.equals("..")){
                if (!stack.empty()){
                    stack.pop();
                }
                continue;
            }
            stack.push(s);
        }
        StringBuilder stringBuilder=new StringBuilder();
        while (!stack.empty()){
            StringBuilder temp=new StringBuilder();
            temp.append('/').append(stack.pop());
            stringBuilder=temp.append(stringBuilder);
        }
        return stringBuilder.length()!=0?stringBuilder.toString():"/";
    }

    public static void main(String[] args) {
        System.out.println(new Solution71().simplifyPath("/a/./b/../../c/"));
    }
}
